<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="tar-examples.html" />
<link rel="prev" href="tarfile-objects.html" />
<link rel="parent" href="module-tarfile.html" />
<link rel="next" href="tar-examples.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>12.5.2 TarInfo Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="12.5.1 tarfile Objects"
  href="tarfile-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="12.5 tarfile  "
  href="module-tarfile.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="12.5.3 Examples"
  href="tar-examples.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="tarfile-objects.html">12.5.1 TarFile Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-tarfile.html">12.5 tarfile  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="tar-examples.html">12.5.3 Examples</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0014520000000000000000"></a><a name="tarinfo-objects"></a>
<br>
12.5.2 TarInfo Objects 
</h2>

<p>
A <tt class="class">TarInfo</tt> object represents one member in a
<tt class="class">TarFile</tt>. Aside from storing all required attributes of a file
(like file type, size, time, permissions, owner etc.), it provides
some useful methods to determine its type. It does <em>not</em> contain
the file's data itself.

<p>
<tt class="class">TarInfo</tt> objects are returned by <tt class="class">TarFile</tt>'s methods
<tt class="method">getmember()</tt>, <tt class="method">getmembers()</tt> and <tt class="method">gettarinfo()</tt>.

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2424' xml:id='l2h-2424' class="class">TarInfo</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>name</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
    Create a <tt class="class">TarInfo</tt> object.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2425' xml:id='l2h-2425' class="method">frombuf</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Create and return a <tt class="class">TarInfo</tt> object from a string buffer.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2426' xml:id='l2h-2426' class="method">tobuf</tt></b>(</nobr></td>
  <td><var>posix</var>)</td></tr></table></dt>
<dd>
    Create a string buffer from a <tt class="class">TarInfo</tt> object.
    See <tt class="class">TarFile</tt>'s <tt class="member">posix</tt> attribute for information
    on the <var>posix</var> argument. It defaults to <tt class="constant">False</tt>.

<p>

<span class="versionnote">New in version 2.5:
The <var>posix</var> parameter.</span>

</dl>

<p>
A <code>TarInfo</code> object has the following public data attributes:

<p>
<dl><dt><b><tt id='l2h-2427' xml:id='l2h-2427' class="member">name</tt></b></dt>
<dd>
    Name of the archive member.
</dl>

<p>
<dl><dt><b><tt id='l2h-2428' xml:id='l2h-2428' class="member">size</tt></b></dt>
<dd>
    Size in bytes.
</dl>

<p>
<dl><dt><b><tt id='l2h-2429' xml:id='l2h-2429' class="member">mtime</tt></b></dt>
<dd>
    Time of last modification.
</dl>

<p>
<dl><dt><b><tt id='l2h-2430' xml:id='l2h-2430' class="member">mode</tt></b></dt>
<dd>
    Permission bits.
</dl>

<p>
<dl><dt><b><tt id='l2h-2431' xml:id='l2h-2431' class="member">type</tt></b></dt>
<dd>
    File type.  <var>type</var> is usually one of these constants:
    <tt class="constant">REGTYPE</tt>, <tt class="constant">AREGTYPE</tt>, <tt class="constant">LNKTYPE</tt>,
    <tt class="constant">SYMTYPE</tt>, <tt class="constant">DIRTYPE</tt>, <tt class="constant">FIFOTYPE</tt>,
    <tt class="constant">CONTTYPE</tt>, <tt class="constant">CHRTYPE</tt>, <tt class="constant">BLKTYPE</tt>,
    <tt class="constant">GNUTYPE_SPARSE</tt>.  To determine the type of a
    <tt class="class">TarInfo</tt> object more conveniently, use the <code>is_*()</code>
    methods below.
</dl>

<p>
<dl><dt><b><tt id='l2h-2432' xml:id='l2h-2432' class="member">linkname</tt></b></dt>
<dd>
    Name of the target file name, which is only present in
    <tt class="class">TarInfo</tt> objects of type <tt class="constant">LNKTYPE</tt> and
    <tt class="constant">SYMTYPE</tt>.
</dl>

<p>
<dl><dt><b><tt id='l2h-2433' xml:id='l2h-2433' class="member">uid</tt></b></dt>
<dd>
    User ID of the user who originally stored this member.
</dl>

<p>
<dl><dt><b><tt id='l2h-2434' xml:id='l2h-2434' class="member">gid</tt></b></dt>
<dd>
    Group ID of the user who originally stored this member.
</dl>

<p>
<dl><dt><b><tt id='l2h-2435' xml:id='l2h-2435' class="member">uname</tt></b></dt>
<dd>
    User name.
</dl>

<p>
<dl><dt><b><tt id='l2h-2436' xml:id='l2h-2436' class="member">gname</tt></b></dt>
<dd>
    Group name.
</dl>

<p>
A <tt class="class">TarInfo</tt> object also provides some convenient query methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2437' xml:id='l2h-2437' class="method">isfile</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if the <tt class="class">Tarinfo</tt> object is a regular
    file.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2438' xml:id='l2h-2438' class="method">isreg</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Same as <tt class="method">isfile()</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2439' xml:id='l2h-2439' class="method">isdir</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is a directory.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2440' xml:id='l2h-2440' class="method">issym</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is a symbolic link.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2441' xml:id='l2h-2441' class="method">islnk</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is a hard link.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2442' xml:id='l2h-2442' class="method">ischr</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is a character device.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2443' xml:id='l2h-2443' class="method">isblk</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is a block device.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2444' xml:id='l2h-2444' class="method">isfifo</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is a FIFO.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2445' xml:id='l2h-2445' class="method">isdev</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
    Return <tt class="constant">True</tt> if it is one of character device, block
    device or FIFO.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="12.5.1 tarfile Objects"
  href="tarfile-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="12.5 tarfile  "
  href="module-tarfile.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="12.5.3 Examples"
  href="tar-examples.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="tarfile-objects.html">12.5.1 TarFile Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-tarfile.html">12.5 tarfile  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="tar-examples.html">12.5.3 Examples</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
